#include <stdio.h>
#include <stdlib.h>

int n = 5;
int edges[][2] = {
    {0, 1},
    {1, 2},
    {3, 4}
};
int m = 3;

int parent[5] = {};
int count = 5;

int find(int x) {
    if (parent[x] != x) {
        parent[x] = find(parent[x]);
    }
    return parent[x];
}

void unionTwo(int x, int y) {
    int xRoot = find(x);
    int yRoot = find(y);
    if (xRoot == yRoot) {
        return;
    }
    parent[xRoot] = yRoot;
    count--;

}



int main () {
    for (int i = 0; i < 5; ++i) {
        parent[i] = i;
    }
    for (int j = 0; j < m; ++j) {
        unionTwo(edges[j][0], edges[j][1]);
    }
    
    printf("%d\n", count);
    return 0;
}